local DIY = require "packages.diy_utility.diy_utility"

local skel = fk.CreateSkill({
    name = "sj5__daili",
    tags = {Skill.Compulsory},
  })
  
  Fk:loadTranslationTable{
    ["sj5__daili"] = "带砺",
    [":sj5__daili"] = "<b>锁定技</b>，你只能使用明置牌；每回合限一次，当你没有可使用的手牌后，你将手牌翻面并摸两张牌。",
  
    ["$sj5__daili1"] = "国朝倾覆，吾宁当为降虏乎！",
    ["$sj5__daili2"] = "弃百姓之所仰，君子不为也。",
  }

  local daili_spec = {
    on_use = function(self, event, target, player, data)
    for _, id in ipairs(player:getCardIds("h")) do
      if table.contains(DIY.getShownCards(player),id) then
        DIY.hideCards(player,id)
      else
        DIY.showCards(player,id)
      end
    end
    if not player.dead then
      player:drawCards(2,skel.name)
    end
  end,
  }

  skel:addEffect(fk.AfterCardsMove, {
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) then
      for _, move in ipairs(data) do
        if (move.from and move.from == player) or (move.to and move.to == player and move.toArea == Card.PlayerHand) then
          return not table.find(player:getCardIds("h"),function (id)
            return #(Fk:getCardById(id):getDefaultTarget(player)) > 0
          end) and player:usedSkillTimes(skel.name) < 1
        end
      end
    end
  end,
  on_use = daili_spec.on_use,
  })

  skel:addEffect(fk.AskForCardUse, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and not table.find(player:getCardIds("h"),function (id)
      local card = Fk:getCardById(id)
      return Exppattern:Parse(data.pattern):match(card) and not player:prohibitUse(card)
    end) and player:usedSkillTimes(skel.name) < 1
  end,
  on_use = daili_spec.on_use,
  })

  skel:addEffect(fk.AfterCardUseDeclared, { --  为使用次数增加这段
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and 
      not table.find(player:getCardIds("h"),function (id)
        return #(Fk:getCardById(id):getDefaultTarget(player)) > 0
      end) and player:usedSkillTimes(skel.name) < 1
  end,
  on_use = daili_spec.on_use,
  })
---[[
skel:addEffect("prohibit", {
  prohibit_use = function (self, player, card)
    if player:hasSkill(skel.name) then
      for _, id in ipairs(player:getCardIds("h")) do
        if id == card.id and not table.contains(DIY.getShownCards(player),card.id)  then
          return true
        end
      end
    end
  end,
})
--]]
  return skel